package com.rongke.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.rongke.mapper.MedicalRecordsMapper;
import com.rongke.model.MedicalRecords;
import com.rongke.service.MedicalRecordsService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @MedicalRecordsServiceImpl
 * @病历ServiceImpl
 * @version : Ver 1.0
 */
@Service
public class MedicalRecordsServiceImpl extends ServiceImpl<MedicalRecordsMapper, MedicalRecords>
                                                                                                implements
                                                                                                MedicalRecordsService {
    @Autowired
    private MedicalRecordsMapper medicalRecordsMapper;

    @Override
    public Page<Map<String, Object>> selectVerifyHistory(Page<Map<String, Object>> page,
                                                         String verifiedDoctorUserId) {
        page.setRecords(baseMapper.selectVerifyHistory(page, verifiedDoctorUserId));
        return page;
    }

    @Override
    public MedicalRecords selectByUserId(String userId) {
        EntityWrapper<MedicalRecords> ew = new EntityWrapper<>();
        ew.eq("user_id", userId);

        List<MedicalRecords> mrList = baseMapper.selectList(ew);
        if (null == mrList || mrList.isEmpty()) {
            return null;
        }

        return mrList.get(0);
    }
}
